<?php

namespace App\Models\Cruise;

use App\Models\BaseModel;
use App\Models\Traits\KfUid;

class CruiseOrderProcessV2Model extends BaseModel
{
    protected $table = 'cruise_order_process_v2';

    use KfUid;

    protected $fillable = [
        'cruiseOrderId',
        'cruiseOrderStatus',
        'type',
        'content',
        'details',
    ];

    const TYPE_DEFAULT = 0;
    const TYPE_AGREE  = 1;
    const TYPE_REJECT = 2;

    const TYPE_TEXT = [
        self::TYPE_DEFAULT => '',
        self::TYPE_AGREE  => '同意',
        self::TYPE_REJECT => '驳回',
    ];

    public static function add(int $cruiseOrderId, int $cruiseOrderStatus, int $type, string $content, array $details = [])
    {
        return self::query()->create([
            'cruiseOrderId'     => $cruiseOrderId,
            'cruiseOrderStatus' => $cruiseOrderStatus,
            'type'              => $type,
            'content'           => $content,
            'details'           => json_encode($details, JSON_UNESCAPED_UNICODE),
        ]);
    }
}
